package com.itheima;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @ProjectName: ybxy6
 * @Titile: Student
 * @Author: 鲁伍加
 * @Description: TODO
 */
@Data
//@AllArgsConstructor
public class Student implements Comparable<Student> {
    private String name;
    private int age;
//    @Override
//    public int compareTo(Student o) {
//        //按照年龄正序排序（升序
//        return this.age-o.age;
//    }
// 无参构造方法（如果需要）
public Student() {
}

    // 带参数的构造方法
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    // getter、setter 和 toString 方法

    @Override
    public int compareTo(Student other) {
        return Integer.compare(this.age, other.age); // 按年龄排序
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }
}
